package com.snake.springboot.custom.controller.base;

import com.snake.springboot.custom.api.model.base.CustRoleAuthModel;
import com.snake.springboot.custom.api.request.base.CustRoleAuthReq;
import com.snake.springboot.custom.api.service.base.CustRoleAuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.snake.common.result.ResponseResult;
import org.snake.common.result.ResponseResultFactory;
import org.snake.common.validate.Create;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>商户管理-角色权限组
 * 类{@code CustRoleAuth} </br>
 * 创建时间2025/2/10 17:43
 *
 * @author yangxt
 * @see
 */
@Api(tags = "商户管理-角色权限策略关系")
@RestController
@RequestMapping("/cust/role-auth")
public class CustRoleAuthController {

    private CustRoleAuthService roleAuthService;
    @Autowired
    public CustRoleAuthController(CustRoleAuthService roleAuthService) {
        this.roleAuthService = roleAuthService;
    }

    @ApiOperation("添加角色权限策略关系")
    @PostMapping("/add")
    public ResponseResult<CustRoleAuthReq> addCustRoleAuth(
            @ApiParam(name = "接口入参", value = "传入json格式", required = true)
            @RequestBody @Validated({Create.class}) CustRoleAuthReq req) {
        CustRoleAuthReq result = roleAuthService.addCustRoleAuth(req);
        return ResponseResultFactory.ucc("添加成功！", result);
    }



    @ApiOperation("查询角色权限策略关系列表")
    @PostMapping("/list")
    public ResponseResult<List<CustRoleAuthModel>> queryCustRoleAuthList(
            @ApiParam(name = "查询条件", value = "传入json类型", required = true)
            @RequestBody CustRoleAuthModel model) {
        List<CustRoleAuthModel> result = roleAuthService.queryCustRoleAuthList(model);
        return ResponseResultFactory.ucc("查询成功！", result);
    }
}
